// 按钮节流
export function throttle(fn: any, gapTime: any) {
  if (gapTime == null || gapTime === undefined) {
    gapTime = 1500;
  }

  let _lastTime: any = null;
  // 返回新的函数
  return function () {
    const _nowTime = +new Date();
    if (_nowTime - _lastTime > gapTime || !_lastTime) {
      fn.apply(this, arguments); // 将this和参数传给原函数
      _lastTime = _nowTime;
    }
  };
}

// 手机号格式验证
export function validatePhoneNumber(phoneNumber: any) {
  const phoneRegex = /^1[34578]\d{9}$/;
  if (phoneRegex.test(phoneNumber)) {
    return true;
  } else {
    return false;
  }
}
